﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Farigola.Engine.Reposit;

namespace Farigola.Engine.PersistXml.TestUnit
{
    class EngineRepositXmlCommonTestUnit
    {
        /// <summary>
        /// create the engine core, init it and return it.
        /// </summary>
        /// <param name="engineReposit"></param>
        /// <returns></returns>
        public static Engine CreateInitEnginePersistXml()
        {
            Engine engine;

            // create a concrete repository, persit data project in a xml file
            IEngineReposit engineReposit = new EngineRepositXml();

            engine = new Engine(engineReposit);

            engine.Init();
            return engine;
        }

        /// <summary>
        /// create the engine core, init it 
        /// and return the workspace.
        /// </summary>
        /// <param name="engineReposit"></param>
        /// <returns></returns>
        public static Workspace CreateInitEnginePersistXmlGetWksp()
        {
            Engine engine= CreateInitEnginePersistXml();
            Workspace wksp = engine.GetWorkspace();

            return wksp;
        }

        /// <summary>
        /// create the engine core, init it ,
        /// create a default project,
        /// and return it.
        /// </summary>
        /// <param name="engineReposit"></param>
        /// <returns></returns>
        public static Project CreateInitEnginePersistXmlCreateProject()
        {
            Engine engine = CreateInitEnginePersistXml();
            Workspace wksp = CreateInitEnginePersistXmlGetWksp();

            // create a project
            Project prj = wksp.CreateActiveProject("prj");
            return prj;
        }

    }
}
